imported patch /home/emellor/block_detach.patch
authoremellor@ewan <emellor@ewan>
Tue, 4 Oct 2005 23:11:30 +0000 (00:11 +0100)
committeremellor@ewan <emellor@ewan>
Tue, 4 Oct 2005 23:11:30 +0000 (00:11 +0100)
tools/python/xen/xend/server/DevController.py
tools/python/xen/xm/main.py

index 7992adc143e415618c08c85ed3cc8a19735a7188..47b850fc61ae53b2954d82c8f6df5e558ae83c58 100644 (file)
@@ -78,8 +78,12 @@ class DevController:
         backpath = xstransact.Read(frontpath, "backend")
 
         xstransact.Remove(frontpath)
-        xstransact.Remove(backpath)
 
+        if backpath:
+            xstransact.Remove(backpath)
+        else:
+            raise VmError("Device not connected")
+           
 
     def configurations(self):
         return map(lambda x: self.configuration(int(x)),
index b7fa555eb232d730618067cafb4449fcc3125d30..1ce9985a1c7635dc94459a4ecc55096e4e323e44 100644 (file)
@@ -166,6 +166,9 @@ def handle_xend_error(cmd, dom, ex):
     if error == "Not found" and dom != None:
         err("Domain '%s' not found when running 'xm %s'" % (dom, cmd))
         sys.exit(1)
+    elif error == "Exception: Device not connected":
+        err("Device not connected")
+        sys.exit(1)
     else:
         raise ex
     
@@ -532,7 +535,12 @@ def xm_block_detach(args):
     arg_check(args,2,"block-detach")
 
     dom = args[0]
-    dev = args[1]
+
+    try:
+        dev = int(args[1])
+    except ValueError, e:
+        err("Invalid device id: %s" % args[1])
+        sys.exit(1)
 
     from xen.xend.XendClient import server
     server.xend_domain_device_destroy(dom, 'vbd', dev)